package practice;
import java.util.Arrays;
public class Day06_1 {
    public static void main(String[] args) {
        //1.求数组元素最大值，并且扩容放到最后边
        int[] _array = new int[10];
        System.out.println("扩容前：");
        for (int i=0;i<_array.length;i++) {
            _array[i] = (int)(Math.random()*100);
            System.out.print(_array[i]+"\t");
        }
        int _max = _array[0];
        for (int i=1;i<_array.length;i++) {
            if (_array[i]>_max) {
                _max = _array[i];
            }
        }
        System.out.println("数组的最大值为："+_max);
        _array = Arrays.copyOf(_array,_array.length+1);
        _array[_array.length-1] = _max;
        System.out.println("扩容后：");
        for (int i=0;i<_array.length;i++) {
            System.out.print(_array[i]+"\t");
        }
        System.out.println();


        //2.方法的练习 参数
        say();

        sayName("张三");

        sayNameAge("李四",50);

        //3.方法的练习 返回值
        double dou1 = _number();
        System.out.println(dou1);

        int sum1 = addition1(9,8);
        System.out.println(sum1);

        int m1 = (int)(Math.random()*100);
        int m2 = (int)(Math.random()*100);
        int sum2 = addition1(m1,m2);
        System.out.println(m1+"+"+m2+"="+sum2);

        int[] array1 = testArray1(5,100);
        System.out.println(array1.length);
        for (int i=0;i<array1.length;i++) {
            System.out.print(array1[i]+"\t");
        }
        System.out.println();

        int[] array2 = testArray1(6,50);
        for (int i=0;i<array2.length;i++) {
            System.out.print(array2[i]+"\t");
        }
    }
    public static void say() {
        System.out.println("你好，我叫xxx!");
    }
    public static void sayName(String name) {
        System.out.println("你好，我的名字是："+name);
    }
    public static void sayNameAge(String name,int age) {
        System.out.println("你好，我叫"+name+",今年"+age+"岁了。");
    }
    public static double _number() {
        return 9.99;
    }
    public static int addition1(int num1,int num2) {
        int sum1 = num1+num2;
        return sum1;
    }
    public static int[] testArray1(int _length,int _max) {
        int[] array1 = new int[_length];
        for (int i=0;i<array1.length;i++) {
            array1[i] = (int)(Math.random()*_max);
        }
        return array1;
    }

}
